# -*- coding: utf-8 -*-

# graphic-pppoe-client - Easy graphic networking manager
#
# Author: GoTLiuM InSPiRiT <gotlium@gmail.com>
#
# Copyright 2010, GoTLiuM InSPiRiT <gotlium@gmail.com>.
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2, as published
# by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranties of
# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
# PURPOSE.  See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program.  If not, see <http://www.gnu.org/licenses/>.
from models.__init__ import getIfnameByConnId
from libraries.fw import addPort, delPort

class Firewall(object):
	
	def setFwRules(self, connId):
		ifName = getIfnameByConnId(connId)
		for row in self.selectFirewall(connId):
			addPort(ifName, row['port'])
		return True

	def delFwRules(self, connId):
		ifName = getIfnameByConnId(connId)
		for row in self.selectFirewall(connId):
			delPort(ifName, row['port'])
		return True
